(library (lib math-procs)
  (export limit-by-interval)
  (import
    (except (rnrs base) let-values map error)
    (only (guile) lambda* λ)))


(define limit-by-interval
  (λ (val min-val max-val)
    "Limit a value by an enclosing interval. Both bounds are
inside the interval. The interval is a closed interval."
    (max min-val
         (min max-val
              val))))
